<template>
  <div class="table-operation-buttons">
    <!-- 查看按钮 -->
    <el-button
      v-if="hasView"
      size="mini"
      type="text"
      icon="el-icon-view"
      @click="$emit('view')"
      title="查看">
      <slot name="view"></slot>
    </el-button>

    <!-- 编辑按钮 -->
    <el-button
      v-if="hasEdit"
      size="mini"
      type="text"
      icon="el-icon-edit"
      @click="$emit('edit')"
      title="编辑">
      <slot name="edit"></slot>
    </el-button>

    <!-- 删除按钮 -->
    <el-button
      v-if="hasDelete"
      size="mini"
      type="text"
      icon="el-icon-delete"
      @click="$emit('delete')"
      title="删除">
      <slot name="delete"></slot>
    </el-button>

    <!-- 其他自定义按钮 -->
    <slot></slot>
  </div>
</template>

<script>
export default {
  name: 'TableOperationButtons',
  props: {
    // 控制按钮显示
    hasView: {
      type: Boolean,
      default: false
    },
    hasEdit: {
      type: Boolean,
      default: false
    },
    hasDelete: {
      type: Boolean,
      default: false
    },

    // 按钮悬浮文字
    viewText: {
      type: String,
      default: ''
    },
    editText: {
      type: String,
      default: ''
    },
    deleteText: {
      type: String,
      default: ''
    }
  }
}
</script>

<style scoped>
.table-operation-buttons {
  display: flex;
  justify-content: center;
}
</style>
